package com.springCloudStudy.controller;


import com.commons.interfaces.entities.Payment;
import com.commons.interfaces.utils.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.loadbalancer.core.ReactorLoadBalancer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @PROJECT_NAME: SpringCloud_Study_atGuiGU
 * @NAME: OrderController
 * @Author: lidongming
 * @DATE: 2022/2/6
 * @Desc:
 */
@RestController
public class OrderController {

    public static final String PAYMENT_URl = "http://PROVIDER-PAYMENT-SERVER";

    @Autowired
    private RestTemplate template;

    @GetMapping("/payment/create")
    public ResponseData<Payment> createOrder(Payment payment){
        ResponseData<Payment>result = template.postForObject(PAYMENT_URl+"/payment", payment,ResponseData.class);
        System.out.println(result.toString());
        return result;
    }

    @GetMapping("/payment")
    public ResponseData<Payment>getRe(){
        ResponseData<Payment>result = template.getForObject(PAYMENT_URl+"/payment/1", ResponseData.class);
        System.out.println(result.toString()+toString());

        return result;
    }

}
